﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/ResponsiveTheme.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TaggerApp.Admin.Pages.EditLoanedDeviceInfo.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>  body {padding-top: 60px;padding-bottom: 40px;}      </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div><a href="<%=ResolveClientUrl("../LoanDeviceList") %>" class="btn btn-inverse">Go Back to Loan Device Manager </a> </div><br />
    <div class="alert alert-success" id="sucessMessage" runat="server">
            Success! Information has been updated. <a href="../LoanDeviceList/">Click Here</a> to view loaned devices.</div>
    <hr />
    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="loanID" DataSourceID="SqlDSDetails" CssClass="table table-bordered table-hover" OnItemUpdated="DetailsView1_ItemUpdated">
        <Fields>
            <asp:BoundField DataField="loanID" HeaderText="loanID" InsertVisible="False" ReadOnly="True" SortExpression="loanID" HeaderStyle-CssClass="hidecol" ItemStyle-CssClass="hidecol">
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>
            <asp:TemplateField HeaderText="status" SortExpression="status">
                <EditItemTemplate>
                    <asp:DropDownList ID="dropDownStatuses" runat="server" SelectedValue='<%# Bind("status") %>'>
                        <asp:ListItem>Loaned</asp:ListItem>
                        <asp:ListItem>Returned</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("status") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("status") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="productID" SortExpression="productID">
                <EditItemTemplate>
                    <asp:TextBox ID="txtBoxProdName" runat="server" Text='<%# Bind("productID")%>' Visible="false"></asp:TextBox>
                    <asp:Label ID="lblProdName" runat="server" Text='<%# Bind("productName") %>'></asp:Label>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("productID") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblProdName" runat="server" Text='<%# Bind("productName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="loanerName" SortExpression="loanerName">
                <EditItemTemplate>
                    <asp:TextBox ID="txtBoxName" runat="server" Text='<%# Bind("loanerName") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("loanerName") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblName" runat="server" Text='<%# Bind("loanerName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="loanerEmail" SortExpression="loanerEmail">
                <EditItemTemplate>
                    <asp:TextBox ID="txtBoxLoanerEmail" runat="server" Text='<%# Bind("loanerEmail") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("loanerEmail") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblLoanerEmail" runat="server" Text='<%# Bind("loanerEmail") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="dateBorrow" SortExpression="dateBorrow">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("dateBorrow", "{0:d}") %>'></asp:Label>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("dateBorrow", "{0:d}") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("dateBorrow", "{0:d}") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="loanTimeID" SortExpression="loanTimeID">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDSTime" DataTextField="loanTimeDesc" DataValueField="loanTimeID" SelectedValue='<%# Bind("loanTimeID") %>'></asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDSTime" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [tblLoanTime]"></asp:SqlDataSource>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("loanTimeID") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblDate" runat="server" Text='<%# Bind("loanTimeDesc") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="borrowerName" SortExpression="borrowerName">
                <EditItemTemplate>
                    <asp:TextBox ID="txtBoxBorrowerName" runat="server" Text='<%# Bind("borrowerName") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("borrowerName") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblBorrowerName" runat="server" Text='<%# Bind("borrowerName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="borrowerEmail" SortExpression="borrowerEmail">
                <EditItemTemplate>
                    <asp:TextBox ID="txtBoxBorrowerEmail" runat="server" Text='<%# Bind("borrowerEmail") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("borrowerEmail") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblBorrowerEmail" runat="server" Text='<%# Bind("borrowerEmail") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="borrowerPhone" SortExpression="borrowerPhone">
                <EditItemTemplate>
                    <asp:TextBox ID="txtBoxBorrowerPhone" runat="server" Text='<%# Bind("borrowerPhone") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("borrowerPhone") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbl" runat="server" Text='<%# Bind("borrowerPhone") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="loanTimeDesc" HeaderText="loanTimeDesc" SortExpression="loanTimeDesc" HeaderStyle-CssClass="hidecol" ItemStyle-CssClass="hidecol">
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="productName" HeaderText="productName" SortExpression="productName" HeaderStyle-CssClass="hidecol" ItemStyle-CssClass="hidecol" >
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>
            <asp:CommandField ShowEditButton="True" ControlStyle-CssClass="btn btn-primary"  ButtonType="Button" >
<ControlStyle CssClass="btn btn-primary"></ControlStyle>
            </asp:CommandField>
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDSDetails" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [tblLoanDevice] WHERE [loanID] = @loanID" InsertCommand="INSERT INTO [tblLoanDevice] ([productID], [dateBorrow], [loanTimeID], [loanerName], [loanerEmail], [borrowerEmail], [borrowerPhone], [borrowerName], [status]) VALUES (@productID, @dateBorrow, @loanTimeID, @loanerName, @loanerEmail, @borrowerEmail, @borrowerPhone, @borrowerName, @status)" SelectCommand="SELECT tblLoanDevice.loanID, tblLoanDevice.productID, tblLoanDevice.dateBorrow, tblLoanDevice.loanTimeID, tblLoanDevice.loanerName, tblLoanDevice.loanerEmail, tblLoanDevice.borrowerEmail, tblLoanDevice.borrowerPhone, tblLoanDevice.borrowerName, tblLoanDevice.status, tblLoanTime.loanTimeDesc, tblProducts.productName FROM tblLoanDevice INNER JOIN tblLoanTime ON tblLoanDevice.loanTimeID = tblLoanTime.loanTimeID INNER JOIN tblProducts ON tblLoanDevice.productID = tblProducts.productID WHERE (tblLoanDevice.loanID = @loanID)" UpdateCommand="UPDATE [tblLoanDevice] SET [productID] = @productID, [dateBorrow] = @dateBorrow, [loanTimeID] = @loanTimeID, [loanerName] = @loanerName, [loanerEmail] = @loanerEmail, [borrowerEmail] = @borrowerEmail, [borrowerPhone] = @borrowerPhone, [borrowerName] = @borrowerName, [status] = @status WHERE [loanID] = @loanID">
        <DeleteParameters>
            <asp:Parameter Name="loanID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="productID" Type="Int32" />
            <asp:Parameter DbType="Date" Name="dateBorrow" />
            <asp:Parameter Name="loanTimeID" Type="Int32" />
            <asp:Parameter Name="loanerName" Type="String" />
            <asp:Parameter Name="loanerEmail" Type="String" />
            <asp:Parameter Name="borrowerEmail" Type="String" />
            <asp:Parameter Name="borrowerPhone" Type="String" />
            <asp:Parameter Name="borrowerName" Type="String" />
            <asp:Parameter Name="status" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="loanID" QueryStringField="id" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="productID" Type="Int32" />
            <asp:Parameter DbType="Date" Name="dateBorrow" />
            <asp:Parameter Name="loanTimeID" Type="Int32" />
            <asp:Parameter Name="loanerName" Type="String" />
            <asp:Parameter Name="loanerEmail" Type="String" />
            <asp:Parameter Name="borrowerEmail" Type="String" />
            <asp:Parameter Name="borrowerPhone" Type="String" />
            <asp:Parameter Name="borrowerName" Type="String" />
            <asp:Parameter Name="status" Type="String" />
            <asp:Parameter Name="loanID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
